package com.test;

import java.io.File;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.FileRequestEntity;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;

/**
 * HTTP工具 用于向http服务器发送订单数据
 * 
 * @author tudongyun
 */
public final class HttpToolKit {

	public static String doPost(String url, String file) throws Exception {
		PostMethod post = new PostMethod(url);
		RequestEntity entity = new FileRequestEntity(new File(file),"utf-8");
		post.setRequestEntity(entity);
		HttpClient client = new HttpClient();
		client.executeMethod(post);
		//设置2分钟等待,便于调试
		//Thread.sleep(120*1000);
		return null;
	}

	public static void main(String[] args) throws Exception {
		String[] fileNames = new String[]{"customerOrders.xml","customerOrders2.xml","customerOrders3.xml"};
		for(String fl:fileNames){
		doPost("http://localhost:7001/order","data/purchaseOrders/"+fl);
		}
	}
}